#include <iostream>
#include <string>
#include <stack>

int main()
{
    std::string sline;
    std::getline(std::cin, sline);

    int i = 0;
    std::string out_str;
    std::stack<int> num_sk;
    std::stack<std::string> str_sk;

    while (i < sline.size())
    {
        if (std::isdigit(sline[i]))
        {
            int num = 0;
            while (std::isdigit(sline[i]))
            {
                num = num * 10 + sline[i] - '0';
                i++;
            }
            num_sk.push(num);
        }
        else if (sline[i] == '[')
        {
            str_sk.push(out_str);
            out_str = "";
            i++;
        }
        else if (sline[i] == ']')
        {
            std::string temp = out_str;
            out_str = str_sk.top();
            str_sk.pop();
            int cnt = num_sk.top();
            num_sk.pop();
            for (int j = 0; j < cnt; j++)
            {
                out_str += temp;
            }
            i++;
        }
        else
        {
            out_str += sline[i];
            i++;
        }
    }

    std::cout << out_str << std::endl;
    return 0;
}